	IDENTIFICATION DIVISION.
	PROGRAM-ID. BUBBLESORT.
	ENVIRONMENT DIVISION.
	DATA DIVISION.
	WORKING-STORAGE SECTION. 
	01 REC. 
	    02 ACCOUNT  OCCURS 21 TIMES.
	     03 ACCOUNT-NO   PIC 9(5).
	     03 NAME         PIC X(18).
	     03 AMOUNT       PIC 9(6).
	77  CH      PIC X.
	77  C       PIC 9  VALUE IS 0.
	77  NUM     PIC 99 VALUE IS 0.
	77  TEMP1   PIC Z(5).
	77  TEMP2   PIC Z(6).
	77  TP      PIC 99.
	77  TEMP    PIC 99.
	77  I       PIC 99 VALUE IS 0.
	77  J       PIC 99.
	
	PROCEDURE DIVISION.
	MAINPARA.
	    IF NOT C = 3 GO TO MENU.
	    STOP RUN.
	    
	WRITEPARA.
	    DISPLAY (1, 1) ERASE.
	    DISPLAY "--- DATA ENTRY ---".
	    GO TO NEWREC.
	NEWREC.    
	    ADD 1 TO I.
	    DISPLAY (LIN, COL) "NAME      : ". 
	    ACCEPT NAME OF ACCOUNT(I).
	    DISPLAY (LIN, COL) "ACCOUNT NO: ". 
	    ACCEPT ACCOUNT-NO OF ACCOUNT(I).
	    DISPLAY (LIN, COL) "AMOUNT    : ". 
	    ACCEPT AMOUNT OF ACCOUNT(I).
	    DISPLAY (LIN, COL) "CONTINUE <Y/N>?: ".
	    ACCEPT CH.
	    DISPLAY " ".
	    IF CH = "Y" GO TO NEWREC.
	    MOVE I TO NUM.
	    GO TO MAINPARA.
	
	OUTPARA.
	    PERFORM PASS1 VARYING I FROM 1 BY 1 UNTIL I > NUM.
	    GO TO DISPARA.
	PASS1. 
	    COMPUTE TEMP = NUM - I.
	    PERFORM PASS2 VARYING J FROM 1 BY 1 UNTIL J > TEMP.  
	PASS2.    
	    COMPUTE TP = J + 1.
	    IF AMOUNT OF ACCOUNT(J) > AMOUNT OF ACCOUNT(TP)
		 MOVE ACCOUNT(J) TO ACCOUNT(21) 
		 MOVE ACCOUNT(TP) TO ACCOUNT(J)
		 MOVE ACCOUNT(21) TO ACCOUNT(TP).
	DISPARA.
	    MOVE 0 TO I.
	    DISPLAY (1, 1) ERASE.
	    DISPLAY "      -------SORTED LIST-------      ".
	    DISPLAY "-------------------------------------".
	    DISPLAY "ACCOUNT-NO  NAME              AMOUNT ".     
	    DISPLAY "-------------------------------------".
	    GO TO DISPLAYING.
	DISPLAYING.
	    ADD 1 TO I.
	    MOVE ACCOUNT-NO OF ACCOUNT(I) TO TEMP1.
	    MOVE AMOUNT     OF ACCOUNT(I) TO TEMP2. 
	    
	    DISPLAY  TEMP1, "       ", NAME OF ACCOUNT(I), 
		      TEMP2.
	    IF I < NUM GO TO DISPLAYING.
	    DISPLAY "-------------------------------------".
	    ACCEPT CH.
	    GO TO MAINPARA.
	MENU.
	    DISPLAY (1, 1) ERASE.
	    DISPLAY " ".
	    DISPLAY "------- MENU --------".
	    DISPLAY " ".
	    DISPLAY " 1. ADD RECORDS".
	    DISPLAY " 2. REPORT     ".
	    DISPLAY " 3. EXIT       ".
	    DISPLAY " ".
	    DISPLAY (LIN, COL) "CHOICE : ".
	    ACCEPT C.
	    IF C = 1  GO TO WRITEPARA.
	    IF C = 2  GO TO OUTPARA.
	    GO TO MAINPARA.
	



